package com.yehongyu.mytools.network.chat;

/**一个接收线程，主要用于接收数据，随便也写了发送数据
 *   程序名称:Receiver.java
 *   程序作用:接收线程类
 *   程序作者:J.J.Y
 */
 
 import javax.swing.JTextArea;
 
 public class Receiver extends Thread
 {
  //接收的信息
  private String Message;
  private JTextArea displayArea;
  Broadcast Recv = new Broadcast();
  //构造函数,
    public Receiver(JTextArea RecvArea)
    {
     displayArea = RecvArea; 
    }
    
    public void run()
    {
     while (true)
     {
      //监听接收数据包
      Message = Recv.GetData();
      //System.out.println(Message);
      //displayArea.setText("11111");
      displayArea.append(Message + "\r\n");
     } 
    }
    
    //发送数据
    public void SendMessage(String InMsg)
    {
     Recv.SendData(InMsg);
    }
 }